import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../utils/general.dart';
import '../components/ffbtn.dart';
import './register.dart';
import '../utils/general.dart';
class Login extends StatelessWidget {

  List<Widget> getWidgetList(BuildContext context) {
    List<Widget> list = [];
    double scale = widthScale(context);
    list.add(SizedBox(
      height:240 * scale,
      child:Padding(
        padding: EdgeInsets.only(top:24 * scale),
        child: Center(
          child:Image.asset('assets/images/logo1.png', width:80, height: 95,)
        ),
      )
    )
  );
    if (FFShareInstance.info.portrait.length > 0) {    
      Widget btn = FFRowBtn(
        title:'退出登录',
        bgColor: Color.fromRGBO(73, 194, 101, 1.0),
        fontSize: 16,
        radius: 4,
        padding: EdgeInsets.symmetric(horizontal:35 * scale),
        onPress: (){
          Provider.of<FFChangeNotifier>(context, listen: false).removeLoginInfo();
          Navigator.of(context).pop();
        },
      );
      list.add(btn);
    }else {
      list.addAll([
        FFRowBtn(
          title:'微信一键登录',
          bgColor: Color.fromRGBO(73, 194, 101, 1.0),
          fontSize: 16,
          radius: 4,
          padding: EdgeInsets.symmetric(horizontal:35 * scale),
        ),
        FFRowBtn(
          title:'手机验证码登录',
          borderColor: Color.fromRGBO(136, 175, 213, 1.0),
          fontSize: 16,
          radius: 4,
          padding: EdgeInsets.fromLTRB(35 * scale, 20 * scale, 35 * scale, 0),
          onPress: (){
            
            Navigator.of(context).push(PageRouteBuilder(fullscreenDialog: true, pageBuilder: (cont, ani1, ani2){
              return Register();
            }));
            print('...');
          },
        )]);
      }
    return list;
  }

  @override
  Widget build(BuildContext context) {
    double scale = widthScale(context);

    return Scaffold(
      appBar:AppBar(
        backgroundColor:Colors.white,
        leading: FlatButton(
          child: Icon(Icons.keyboard_arrow_left, size:35.0, color:Colors.grey[200]),
          onPressed: ()=>Navigator.of(context).pop()),
      ),
      body:Column(
        mainAxisSize: MainAxisSize.min,
        children: getWidgetList(context),
      )
    );
  }
}
